/**
 * There are <a href="https://github.com/thinkgem/jeesite">JeeSite</a> code generation
 */
package com.thinkgem.jeesite.modules.bls.entity;

import java.util.Date;
import java.util.Map;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;

import org.activiti.engine.history.HistoricProcessInstance;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.validator.constraints.Length;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.thinkgem.jeesite.common.persistence.BaseEntity;
import com.thinkgem.jeesite.common.utils.excel.annotation.ExcelField;
import com.thinkgem.jeesite.modules.sys.entity.Office;
import com.thinkgem.jeesite.modules.sys.entity.User;

/**
 * 信贷分析Entity
 * 
 * @author edpdennis
 * @version 2013-04-19
 */
@Entity
@Table(name = "bls_loan")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Loan extends BaseEntity {

	private static final long serialVersionUID = 1L;
	private Long id; // 编号
	@JsonIgnore  
	private Office office; // 用户 
	@JsonIgnore 
	private User user; // 名称
	private String processInstanceId;//流程ID
	private String officerid;
	private String type; // 备注
	private Date startdate; // 创建日期
	private Date enddate; // 创建日期
	private Float amount; // 创建日期
	private Float balance; // 创建日期
	private Float interes; // 创建日期
	private Float interestactual;
	private Float interestbalance;
	private String ischeck; // --是否审核通过 1通过，2等待审核，3不通过
	// -- 临时属性 --//

	// 流程任务
	private Task task;

	private Map<String, Object> variables;

	// 运行中的流程实例
	private ProcessInstance processInstance;

	// 历史的流程实例
	private HistoricProcessInstance historicProcessInstance;

	// 流程定义
	private ProcessDefinition processDefinition;

	public Loan() {
		// this.startdate = new Date();
		// this.enddate = new Date();
		this.ischeck = STATUS_RELEASE;
	}

	public Loan(Long id) {
		this();
		this.id = id;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@ExcelField(title = "贷款编号", type = 1, align = 2, sort = 1)
	@Column(name = "loan_id")
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@ManyToOne
	@JoinColumn(name = "dep_id")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	@NotNull(message = "所属部门不能为空")
	@ExcelField(title = "所属部门", align = 2, sort = 20)
	public Office getOffice() {
		return office;
	}

	public void setOffice(Office office) {
		this.office = office;
	}

	@Column(name = "loan_officer_id")
	@Length(min = 1, max = 100)
	@ExcelField(title = "信贷人员", align = 2, sort = 30)
	@NotNull(message = "信贷人员不能为空")
	public String getOfficerid() {
		return officerid;
	}

	public void setOfficerid(String officerid) {
		this.officerid = officerid;
	}
	@ManyToOne
	@JoinColumn(name="loan_user_id")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	@ExcelField(title = "信贷人员", align = 2, sort = 30)
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}
	@Column(name = "loan_type")
	@Length(min = 1, max = 1)
	@ExcelField(title = "信贷类型", align = 2, sort = 30)
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	@Column(name = "loan_start_date")
	@NotNull
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@ExcelField(title = "贷款开始时间", type = 0, align = 1, sort = 90)
	public Date getStartdate() {
		return startdate;
	}

	public void setStartdate(Date startdate) {
		this.startdate = startdate;
	}

	@Column(name = "loan_end_date")
	@NotNull
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@ExcelField(title = "贷款结束时间", type = 0, align = 1, sort = 90)
	public Date getEnddate() {
		return enddate;
	}

	public void setEnddate(Date enddate) {
		this.enddate = enddate;
	}

	@Column(name = "loan_amount")
	@ExcelField(title = "贷款金额", type = 0, align = 1, sort = 90)
	public Float getAmount() {
		return amount;
	}

	public void setAmount(Float amount) {
		this.amount = amount;
	}

	@Column(name = "loan_balance")
	@ExcelField(title = "贷款余额", type = 0, align = 1, sort = 90)
	public Float getBalance() {
		return balance;
	}

	public void setBalance(Float balance) {
		this.balance = balance;
	}

	@Column(name = "loan_interest")
	@ExcelField(title = "应收利息", type = 0, align = 1, sort = 90)
	public Float getInteres() {
		return interes;
	}

	public void setInteres(Float interes) {
		this.interes = interes;
	}
	public String getProcessInstanceId() {
		return processInstanceId;
	}

	public void setProcessInstanceId(String processInstanceId) {
		this.processInstanceId = processInstanceId;
	}
	@Column(name = "loan_interest_actual")
	@ExcelField(title = "实收利息", type = 0, align = 1, sort = 90)
	public Float getInterestactual() {
		return interestactual;
	}

	public void setInterestactual(Float interestactual) {
		this.interestactual = interestactual;
	}

	@Column(name = "loan_interest_balance")
	@ExcelField(title = "未收利息", type = 0, align = 1, sort = 90)
	public Float getInterestbalance() {
		return interestbalance;
	}

	public void setInterestbalance(Float interestbalance) {
		this.interestbalance = interestbalance;
	}

	@Column(name = "loan_is_check")
	@Length(min = 1, max = 1)
	@ExcelField(title = "审核状态", type = 0, align = 1, sort = 90)
	public String getIscheck() {
		return ischeck;
	}

	public void setIscheck(String ischeck) {
		this.ischeck = ischeck;
	}

	@Transient
	public Task getTask() {
		return task;
	}

	public void setTask(Task task) {
		this.task = task;
	}

	@Transient
	public Map<String, Object> getVariables() {
		return variables;
	}

	public void setVariables(Map<String, Object> variables) {
		this.variables = variables;
	}

	@Transient
	public ProcessInstance getProcessInstance() {
		return processInstance;
	}

	public void setProcessInstance(ProcessInstance processInstance) {
		this.processInstance = processInstance;
	}

	@Transient
	public HistoricProcessInstance getHistoricProcessInstance() {
		return historicProcessInstance;
	}

	public void setHistoricProcessInstance(
			HistoricProcessInstance historicProcessInstance) {
		this.historicProcessInstance = historicProcessInstance;
	}

	@Transient
	public ProcessDefinition getProcessDefinition() {
		return processDefinition;
	}

	public void setProcessDefinition(ProcessDefinition processDefinition) {
		this.processDefinition = processDefinition;
	}
}
